feat: add internationalization with gt-next #1283
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR adds comprehensive internationalization (i18n) support to the Comp platform using the gt-next library from General Translation. The implementation includes:
Scope and Limitations:
/apps/app
This implementation was created by Locadex, an AI internationalization engineer that automatically analyzes codebases and implements our i18n library
gt-next
.Visual Demo
trycompai-locadex.mp4
Video Demo:
How to Demo This Internationalized App
To test the internationalization features:
Checkout the branch:
Install dependencies:
Run the application:
Switch locales:
Technical Implementation Overview
This implementation uses the gt-next library with the following key components:
Core Setup Files:
GTProvider
- Added to the root layout (app/layout.tsx
) to provide translation contextgt.config.json
- Configuration file specifying locales, project ID, and translation file locationsloadTranslations.ts
- Handles loading local translation files from/public/_gt/[locale].json
How It Works:
<T>
components automatically translates (e.g.,<T><p>Hello World</p></T>
)useGT()
hook in client components orgetGT()
function in server components:<LocaleSelector>
component updates all translated content in real-timeDevelopment Features:
To test different translation modes, you can:
loadTranslations.ts
to_loadTranslations.ts
to disable local files and switch to CDN mode (requiresGT_API_KEY
andGT_PROJECT_ID
)For complete implementation details, visit our documentation.
Expanding Internationalization
Adding New Locales
To add additional languages to your application:
Configure gt-next CLI:
cd apps/app npx gtx-cli configure
Generate translations:
Note: This requires an API key (see authentication below)
Authenticate (for translation generation):
Get your API key by creating an account at https://generaltranslation.com/
Automated Internationalization with Locadex GitHub App
For continuous internationalization install our Locadex GitHub App:
Installation Steps:
Create Account: Visit https://generaltranslation.com/
Connect to GitHub: Click "Connect to GitHub"
Note: This routes through Stripe for our Pro plan, but includes a free month trial
Install GitHub App: Follow the installation flow on github
comp
repositoryRepository Setup: After installation, you'll see your repository listed
Click the "Connect" button to access configuration.
Configure Locadex:
./apps/app
(for monorepos)bun
Since this PR already includes the setup, you can skip installation and have Locadex monitor for new PRs.
How Locadex Works:
For detailed documentation, visit: https://generaltranslation.com/en/docs/platform
Contact & Support
Questions or interested in using our internationalization platform?
📧 Contact: [email protected]
💬 Slack: Feel free to add me to a slack channel for direct support
🌐 Platform: https://generaltranslation.com/
Mandatory Tasks
How should this be tested?
Environment Setup:
GT_API_KEY
andGT_PROJECT_ID
from the General Translation platformTest Scenarios:
Locale Switching:
Content Coverage:
User Experience:
Expected Results:
Checklist